package com.bestdreamer.other;

import java.util.Scanner;

public class MoveTest {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入 A 组字符串...");
        String a = sc.next();
        if(a.length() > 6){
            System.out.println("输入的字符串不能超过 100 个字符，请重新输入...");
            a = sc.next();
        }

        System.out.println("请输入 B 组字符串...");
        String b = sc.next();
        System.out.println(move(a, b));
    }

    public static String move(String a, String b) {
        if (a.equals(b)) {
            return "True";
        }
        if(a.length() != b.length()){
            return "False";
        }

        String temp = a;
        for(int i = 0;i<a.length();i++){
            temp = move(temp);
            if(temp.equals(b)){
                return "True";
            }
        }
        return "False";
    }

    public static String move(String str) {
        String temp = str.substring(1);
        String newA = temp + str.charAt(0);
        return newA;
    }
}
